/**
 * 
 */
package cn.softTank.BpelModelImpl;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.softTank.BpelModel.FromPart;
import cn.softTank.BpelModel.FromParts;

/**
 * @author Yuzone (smartzxy@gmail.com)
 * 
 */
public class FromPartsImpl implements FromParts {

	private List<FromPart> fromPart;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.softTank.BpelModel.FromParts#addFromPart(cn.softTank.BpelModel.FromPart
	 * )
	 */
	@Override
	public void addFromPart(FromPart value) {
		if (fromPart == null)
			fromPart = new ArrayList<FromPart>();
		fromPart.add(value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.FromParts#getFromPart()
	 */
	@Override
	public List<FromPart> getFromPart() {
		return fromPart;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.FromParts#removeFromPartAt(int)
	 */
	@Override
	public void removeFromPartAt(int index) {
		if (fromPart != null && index < fromPart.size())
			fromPart.remove(index);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.FromParts#setFromPart(java.util.List)
	 */
	@Override
	public void setFromPart(List<FromPart> value) {
		fromPart = value;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toElement()
	 */
	@Override
	public Element toElement() {
		Element e = DocumentHelper.createElement("fromParts");
		if (fromPart != null)
			for (int i = 0; i < fromPart.size(); i++)
				e.add(fromPart.get(i).toElement());
		return e;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toXml()
	 */
	@Override
	public String toXml() {
		// TODO Auto-generated method stub
		return null;
	}

}
